#ifndef PARSE8583_H
#define PARSE8583_H

#include <QtWidgets>
#include "Domain8583.h"

typedef enum
{
    APPARENT,
    INTENSION
}OutputStyle;

typedef enum
{
    ICBC = 0,
    PETROCHINA,
    UNIONPAY
}Version;

class Parse8583 : public QWidget
{
    Q_OBJECT

public:
    Parse8583(QWidget *parent = 0);
    ~Parse8583();
    void dsptohex(char *dsp, char *hex, int hex_count);
    void hextodsp(char *hex, char *dsp, int hex_count);
    void adjustButtonStatus();

public slots:
    int parseData(FieldInfo *pFieldInfo, QString originalData);
    //void setOutputStyle(bool);
    void displayResult();
    void currMessageParse();
    void prevMessageParse();
    void nextMessageParse();

signals:
    void parseDone();

private:
    int parseBitMap(unsigned char *bitMap);

private:
    QLabel *dataLabel;
    QLabel *resultLabel;
    QPushButton *parseButton;
    QPushButton *prevButton;
    QPushButton *nextButton;
    QTextEdit *dataEdit;
    QTextEdit *resultEdit;
    QString resultString;
    QGroupBox *versionBox;
    QComboBox *versionCombo;
    QBitArray BitMap;
    QMap<int, QByteArray> domain;
    bool parseSuccess;
    QString errMsg;
    int totalLen;   //报文内容长度，正确情况下等于报文数据前两个字节的数值
    QList< QPair<int, QString> > history;
    int currentIndex;
    int maxHistorySize;
};

#endif // PARSE8583_H
